import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/svg.dart';

class HeadView extends StatelessWidget {
  const HeadView({super.key});

  @override
  Widget build(BuildContext context) {
    int currentIndex = 0;

    return Container(
      height: 375,
      width: double.infinity,
      decoration: const BoxDecoration(
        image: DecorationImage(
          image: AssetImage('assets/images/head.jpeg'),
          fit: BoxFit.cover,
        ),
      ),
      child: Stack(
        children: [
          Column(
            mainAxisAlignment: MainAxisAlignment.end,
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [0, 1, 2]
                    .map((index) {
                      return [
                        Container(
                          width: 32,
                          height: 32,
                          decoration: BoxDecoration(
                            // 如果 currentIndex 等于当前 index ，边框为紫色，粗细为1
                            image: const DecorationImage(
                                image: AssetImage('assets/images/head.jpeg'),
                                fit: BoxFit.cover),

                            border: currentIndex == index
                                ? Border.all(color: Colors.purple, width: 1)
                                : null,
                            // 圆角 4

                            borderRadius:
                                const BorderRadius.all(Radius.circular(4)),
                          ),
                        ),
                        const SizedBox(
                          width: 10,
                        ),
                      ];
                    })
                    .expand((item) => item)
                    .toList(),
              ),
              const SizedBox(
                height: 10,
              ),
              SvgPicture.asset(
                'assets/images/block_head.svg',
                width: MediaQuery.of(context).size.width,
                fit: BoxFit.cover,
              )
            ],
          ),
          Positioned(
            bottom: 0,
            left: 0,
            right: 0,
            child: Container(
              height: 50,
              alignment: Alignment.center,
              child: SizedBox(
                width: 66,
                height: 22,
                child: Stack(
                  children: [
                    SvgPicture.asset(
                      'assets/images/bubble.svg',
                      width: 66,
                      height: 22,
                      fit: BoxFit.cover,
                    ),
                    const SizedBox(
                      height: 16,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceAround,
                        children: [
                          SizedBox(width: 6),
                          Icon(
                            IconData(
                              0xe65f,
                              fontFamily: 'IconFont',
                            ), // 0xe800 是图标代码
                            size: 12,
                            color: Colors.white,
                          ),
                          Icon(
                            IconData(
                              0xeae0,
                              fontFamily: 'IconFont',
                            ), // 0xe800 是图标代码
                            size: 14,
                            color: Colors.white,
                          ),
                          Text(
                            '08"',
                            style: TextStyle(
                              color: Colors.white,
                              fontSize: 12,
                            ),
                          ),
                          SizedBox(width: 6),
                        ],
                      ),
                    )
                  ],
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
